// 颜色修复测试脚本
console.log('🎨 开始颜色修复测试...')

// 获取游戏状态
const gameStore = window.__VUE_APP__._instance.provides.gameStore

if (gameStore) {
  console.log('✅ 找到游戏 Store')
  
  const players = gameStore.players || []
  const currentPlayer = gameStore.currentPlayer
  
  console.log('当前玩家:', currentPlayer)
  console.log('玩家列表:', players)
  
  if (players.length > 0) {
    console.log('\n=== 颜色修复测试结果 ===')
    
    players.forEach((player, index) => {
      console.log(`\n玩家 ${index + 1}: ${player.nickname}`)
      console.log(`  AvatarColor: "${player.avatarColor}" (类型: ${typeof player.avatarColor})`)
      console.log(`  BrushColor: "${player.brushColor}" (类型: ${typeof player.brushColor})`)
      console.log(`  兼容Color: "${player.color}" (类型: ${typeof player.color})`)
      
      // 检查颜色是否为空或undefined
      if (!player.avatarColor) {
        console.log('  ❌ AvatarColor 为空或undefined')
      } else {
        console.log('  ✅ AvatarColor 正常')
      }
      if (!player.brushColor) {
        console.log('  ❌ BrushColor 为空或undefined')
      } else {
        console.log('  ✅ BrushColor 正常')
      }
      if (!player.color) {
        console.log('  ❌ 兼容Color 为空或undefined')
      } else {
        console.log('  ✅ 兼容Color 正常')
      }
    })
    
    // 检查当前玩家
    if (currentPlayer) {
      console.log(`\n当前玩家: ${currentPlayer.nickname}`)
      console.log(`  头像颜色: "${currentPlayer.avatarColor}" (类型: ${typeof currentPlayer.avatarColor})`)
      console.log(`  画笔颜色: "${currentPlayer.brushColor}" (类型: ${typeof currentPlayer.brushColor})`)
      
      if (!currentPlayer.avatarColor) {
        console.log('  ❌ 当前玩家头像颜色为空')
      } else {
        console.log('  ✅ 当前玩家头像颜色正常')
      }
      if (!currentPlayer.brushColor) {
        console.log('  ❌ 当前玩家画笔颜色为空')
      } else {
        console.log('  ✅ 当前玩家画笔颜色正常')
      }
    }
    
    // 检查颜色唯一性
    const avatarColors = players.map(p => p.avatarColor).filter(c => c)
    const brushColors = players.map(p => p.brushColor).filter(c => c)
    
    console.log(`\n头像颜色数量: ${avatarColors.length}`)
    console.log(`画笔颜色数量: ${brushColors.length}`)
    
    if (avatarColors.length > 0) {
      const uniqueAvatarColors = new Set(avatarColors)
      console.log(`头像颜色唯一性: ${avatarColors.length === uniqueAvatarColors.size ? '✅' : '❌'}`)
      console.log('头像颜色列表:', avatarColors)
    }
    
    if (brushColors.length > 0) {
      const uniqueBrushColors = new Set(brushColors)
      console.log(`画笔颜色唯一性: ${brushColors.length === uniqueBrushColors.size ? '✅' : '❌'}`)
      console.log('画笔颜色列表:', brushColors)
    }
    
  } else {
    console.log('❌ 没有玩家')
  }
} else {
  console.log('❌ 找不到游戏 Store')
}

console.log('\n测试完成')
